{% extends "base.html" %}
{% load display static %}

{% block title %}Minijack: Live of Tests{% endblock %}

{% block stylesheets %}
  <link rel="stylesheet" type="text/css"
      href="{% static 'css/filter.css' %}">
{% endblock %}

{% block javascripts %}
  <script type="text/javascript" language="javascript"
      src="{% static 'js/tests_life.js' %}"></script>
  <script type="text/javascript" language="javascript"
      src="{% static 'js/filter.js' %}"></script>
  <script type="text/javascript" language="javascript">
    var aaFailedDevices = {{ failed_devices|Jsonify }};
    var aaDeviceInfo = {{ device_info|Jsonify }};
    var aParams = {{ request.GET.dict|Jsonify }};
  </script>
{% endblock %}

{% block body %}
  <h1>Minijack: Life of Tests</h1>
  {% include "filter.html" %}
  <div id="buttons_div">
    <button value="full_path">Group by Path</button>
    <button value="short_path">Group by Path Suffix</button>
    <button value="pytest_name">Group by Pytest Name</button>
  </div>
  <br/>
  <table id="test_table" width="100%">
    <thead>
      <tr>
        <th></th>
        <th>name</th>
        <th>latest_test_time</th>
        <th>num_tested</th>
        <th>pass_rate</th>
        <th>fail_rate</th>
        <th>duration_average</th>
        <th>duration_min</th>
        <th>duration_max</th>
        <th>duration_median</th>
        <th>duration_stddev</th>
        <th>try_average</th>
        <th>try_min</th>
        <th>try_max</th>
        <th>try_median</th>
        <th>try_stddev</th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <th></th>
        <th>name</th>
        <th>latest_test_time</th>
        <th>num_tested</th>
        <th>pass_rate</th>
        <th>fail_rate</th>
        <th>duration_average</th>
        <th>duration_min</th>
        <th>duration_max</th>
        <th>duration_median</th>
        <th>duration_stddev</th>
        <th>try_average</th>
        <th>try_min</th>
        <th>try_max</th>
        <th>try_median</th>
        <th>try_stddev</th>
      </tr>
    </tfoot>
    <tbody>
      {% for test in test_stats %}
      <tr>
        <td width="20">{% if test.path in failed_devices %}
          <img src="{% static 'images/details_open.png' %}"/>{% endif %}
        </td>
        <td>
          <a href="{% url 'test' %}?type={{ order }}&name={{ test.path }}"
            class="datatable_link">
            {{ test.path }}
          </a>
        </td>
        <td>{{ test.latest_time|slice:"5:16" }}</td>
        <td>{{ test.num_test }}</td>
        <td>{{ test.pass_rate|floatformat:4 }}</td>
        <td>{{ test.fail_rate|floatformat:4 }}</td>
        <td>{{ test.duration_stats.avg|DisplayFloat }}</td>
        <td>{{ test.duration_stats.min|DisplayFloat }}</td>
        <td>{{ test.duration_stats.max|DisplayFloat }}</td>
        <td>{{ test.duration_stats.median|DisplayFloat }}</td>
        <td>{{ test.duration_stats.stddev|DisplayFloat }}</td>
        <td>{{ test.try_stats.avg|DisplayFloat }}</td>
        <td>{{ test.try_stats.min|DisplayFloat }}</td>
        <td>{{ test.try_stats.max|DisplayFloat }}</td>
        <td>{{ test.try_stats.median|DisplayFloat }}</td>
        <td>{{ test.try_stats.stddev|DisplayFloat }}</td>
      </tr>{% endfor %}
    </tbody>
  </table>
{% endblock %}
